package com.liang.controller;


import com.liang.pojo.Armyandexcuse;
import com.liang.empty.Result;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;;
import java.util.List;
import com.liang.service.ArmyandexcuseService;
/**
 *@作者:lsk
 *Controller接口
 *@Date:2023/10/22
*/
@RestController
@RequestMapping("/ArmyandexcuseURL")
public class ArmyandexcuseController {


	@Autowired
	private ArmyandexcuseService armyandexcuseservice;


	/**
	根据Army_idAndExcuse_id查询
	*/
	@GetMapping("/selectByArmy_idAndExcuse_id/{army_id}/{excuse_id}")
	public Result selectByArmy_idAndExcuse_id(@PathVariable(value = "army_id") Long army_id, @PathVariable(value = "excuse_id") Long excuse_id){
		return Result.buildMessage(armyandexcuseservice.selectByArmy_idAndExcuse_id(army_id, excuse_id),"查询成功",200);
	}


	/**
	根据Army_idAndExcuse_id更新
	*/
	@PostMapping("/updateByArmy_idAndExcuse_id")
	public Result updateByArmy_idAndExcuse_id(@RequestBody Armyandexcuse demo){
		return Result.buildMessage(armyandexcuseservice.updateByArmy_idAndExcuse_id( demo),"修改成功",0);
	}



	/**
	根据Army_idAndExcuse_id删除
	*/
	@GetMapping("/deleteByArmy_idAndExcuse_id/{army_id}/{excuse_id}")
	public Result deleteByArmy_idAndExcuse_id(@PathVariable(value = "army_id") Long army_id, @PathVariable(value = "excuse_id") Long excuse_id){
		return Result.buildMessage(armyandexcuseservice.deleteByArmy_idAndExcuse_id(army_id, excuse_id),"删除成功",0);
	}





	/**
	 insert:(插入)
	*/
	@PostMapping("/insert")
	public Result insert(@RequestBody Armyandexcuse demo){
		Result.buildSuccess(armyandexcuseservice.insert(demo));
		return Result.buildMessage(demo,"添加成功",0);
	}



	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	@PostMapping("/insertOrUpdate")
	public Result insertOrUpdate(@RequestBody Armyandexcuse demo){
		return Result.buildMessage(armyandexcuseservice.insertOrUpdate(demo),"插入或更新成功",200);
	}



	/**
	 insertBath:(批量插入)
	*/
	@PostMapping("/insertBatch")
	public Result insertBatch(@RequestBody List<Armyandexcuse> list){
		return Result.buildMessage(armyandexcuseservice.insertBatch(list),"批量插入成功",200);
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	@PostMapping("/insertOrUpdateBatch")
	public Result insertOrUpdateBatch(@RequestBody List<Armyandexcuse> list){
		return Result.buildMessage(armyandexcuseservice.insertOrUpdateBatch(list),"批量更新成功",200);
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	@PostMapping("/selectList")
	public Result selectList(@RequestBody Map<String,Object> param){
		Map map = new HashMap<String,Object>();
		if(param.get("pageNum") != null){
			map.put("total",armyandexcuseservice.selectCount(param));
		}
		map.put("data",armyandexcuseservice.selectList(param));
		return Result.buildMessage(map,"查询成功",200);
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	@PostMapping("/selectCount")
	public Result selectCount(@RequestBody Map<String,Object> param){
		return Result.buildMessage(armyandexcuseservice.selectCount(param),"查询数量成功",200);
	}



}